using System;
using L=Science.Physics.GeneralPhysics;

namespace Serway.Chapter26
{
	/// <summary>
	/// Example08: The H_2O Molecule 
	/// The water (H_2O) molecule has an electric dipole moment 
	/// of 6.3 \times 10^{-30} C.m. A sample contains 10^{21} water molecules,
	/// with the dipole moments all oriented in the direction of an 
	/// electric field of magnitude 2.5 \times 10^5 N/C.  How much work is 
	/// required to rotate the dipoles from this orientation (\theta  = 0^{\circle})
	/// to one in which all the moments are perpendicular 
	/// to the field (\theta = 90^{\circle})?
	/// </summary>
	public class Example08
	{
		public Example08()
		{
		}
		private string result;
		public string Result
		{
			get{return result;}
		}
		public void Compute()
		{
			L.ElectricDipoleMoment p = new L.ElectricDipoleMoment();
			p.Z = 6.3E-30;
			L.ElectricField E = new L.ElectricField();
			E.Z = 2.5E5;
			L.PotentialEnergy U1 = p.PotentialEnergyInElectricField(E);
			E.Z = 0.0;
			E.X = 2.5E5;
			L.PotentialEnergy U2 = p.PotentialEnergyInElectricField(E);
       		result+=Convert.ToString(U2.J - U1.J)+"\r\n";
			result+=Convert.ToString(1.0E21*(U2.J - U1.J));
		}
	}
}
